home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import time
- import commands
- from Variable import Variable
-
- class Log:
-
- def __init__(self):
- self.variable = Variable()
- self.msgs = []
- self.wrapping = self.variable.get_constant('disabled')
- self.status = self.init_status_log()
-
-
- def init_status_log(self):
- if not self.variable.dev:
- log_recorder = commands.getstatusoutput(self.variable.get_command('get_log_file'))
- else:
- log_recorder = commands.getstatusoutput(self.variable.get_command('get_log_file_dev'))
- if log_recorder[0] == 0:
- log_split = log_recorder[1].split('\n')
- for log_line in log_split:
- if log_line != '':
- self.msgs.append(log_line)
- continue
-
-
- if not self.variable.dev:
- command = commands.getstatusoutput(self.variable.get_command('cfg_gufw_log'))
- else:
- command = commands.getstatusoutput(self.variable.get_command('cfg_gufw_log_dev'))
- if command[0] == 0:
- return self.variable.get_constant('gufw_log_on')
- return self.variable.get_constant('gufw_log_off')
-
-
- def add_log(self, status, msg_log):
- if status == self.variable.get_constant('gufw_log_off'):
- return None
- actual_time = '[' + time.strftime('%x %X') + '] '
- msg = actual_time + str(msg_log)
- self.msgs.append(msg)
- if not self.variable.dev:
- commands.getstatusoutput(self.variable.get_command('append_log_file').replace('&', msg))
- else:
- commands.getstatusoutput(self.variable.get_command('append_log_file_dev').replace('&', msg))
-
-
- def get_log(self):
- return self.msgs
-
-
- def refresh_log(self):
- self.msgs = []
- if not self.variable.dev:
- commands.getstatusoutput(self.variable.get_command('refresh_log_file'))
- else:
- commands.getstatusoutput(self.variable.get_command('refresh_log_file_dev'))
-
-
- def set_wrapping(self, wrapping):
- self.wrapping = wrapping
- return wrapping
-
-
- def get_wrapping(self):
- return self.wrapping
-
-
-